In [1]:
import time
from qumulo.rest_client import RestClient
In [2]:
def get_throughput_data(rc):
results = {}
for node in rc.cluster.list_nodes():
node_id = node['id']
ns = rc.network.get_network_status_v2(1,node_id)
results[node_id] = ns['interface_details']
return results
def sizeof_fmt(num, suffix='B'):
for unit in ['','K','M','G','T','P','E','Z']:
if abs(num) < 1000.0:
return "%3.1f%s%s" % (num, unit, suffix)
num /= 1000.0
return "%.1f%s%s" % (num, 'Yi', suffix)
In [4]:
rc = RestClient("<qumulo-cluster>", 8000)
rc.login("<qumulo-user>", "<qumulo-password>");
interval_count = 5
interval_time_seconds = 5
previous_result = None
for i in range(0, interval_count+1):
current_result = get_throughput_data(rc)
if previous_result is not None:
for node_id, current_data in current_result.iteritems():
time_diff = (int(current_data['timestamp']) - int(previous_result[node_id]['timestamp'])) / 1000
sent_diff = int(current_data['bytes_sent']) - int(previous_result[node_id]['bytes_sent'])
recv_diff = int(current_data['bytes_received']) - int(previous_result[node_id]['bytes_received'])
print("Node:%3s -- sent: %s/s -- recv: %s/s" % ( node_id,
sizeof_fmt(sent_diff / time_diff),
sizeof_fmt(recv_diff / time_diff),
))
print("") # line break
previous_result = current_result
time.sleep(interval_time_seconds)
In [ ]: